home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWPOSTEX_H
- #define FWPOSTEX_H
- //========================================================================================
- //
- // File: FWPostEx.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWSPOSTE_H
- #include "FWSPostE.h"
- #endif
-
- #ifndef FWPRITAS_H
- #include "FWPriTas.h"
- #endif
-
- //========================================================================================
- // CLASS FW_CPostedException
- //========================================================================================
-
- class FW_CPostedException
- {
-
- public:
-
- static void Initialize(FW_SPrivPostedExceptionGlobals& globals);
- // Initialize. Should only be called once, before any exception is posted.
- // Exception buffer is allocated as maxExceptionSize bytes.
-
- static void Terminate();
- // Cleanup. Releases exception buffer.
-
- static void PostException(const _FW_CException& exception);
- // Post an exception.
- // No-op if posted exception already pending.
-
- static short IsPendingException();
- // Returns 1 if an exception has been posted and not yet thrown.
- // Returns 0 otherwise.
-
- static void ThrowPostedException();
- // Throw the posted exception.
- // It is a no-op to invoke this function if no exception is pending.
-
- static FW_SPrivPostedExceptionGlobals& GetPostedExceptionGlobals();
-
- private:
-
- enum
- {
- kPostedExceptionGlobals = 116
- };
-
- };
-
- //========================================================================================
- // FW_CPostedException inline functions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CPostedException::GetPostedExceptionGlobals
- //----------------------------------------------------------------------------------------
-
- inline FW_SPrivPostedExceptionGlobals& FW_CPostedException::GetPostedExceptionGlobals()
- {
- FW_SPrivPostedExceptionGlobals *globals = (FW_SPrivPostedExceptionGlobals*)
- FW_CPrivTaskGlobals::GetTaskGlobals(kPostedExceptionGlobals);
- if (globals->gInitialized == 0)
- Initialize(*globals);
- return *globals;
- }
-
- inline short FW_CPostedException::IsPendingException()
- {
- return GetPostedExceptionGlobals().gPending;
- }
-
- #endif
-